import javax.swing.plaf.IconUIResource;
import java.lang.reflect.Array;
import java.util.Arrays;
import java.lang.Math;


public class Class4 {

    public static void main3(String[] args) {
        int[] arr = {1,2,3};
        int[] arr1 = arr.clone();     // 这里的 .clone 是深拷贝
        arr[0] = 10;
        for (int e : arr) {
            System.out.print(e + " ");
        }
        System.out.println();
        for (int e : arr1) {
            System.out.print(e + " ");
        }


        // 如果 arr 里存的元素的地址，则.clone()也是浅拷贝
    }
    public static void main2(String[] args) {
        int[] arr1 = {1, 2, 3};
        int[] ret = Arrays.copyOf(arr1, arr1.length);

        int[] arr2 = new int[5];
        System.arraycopy(arr1, 0, arr2, 0, Math.min(arr2.length, arr1.length));

        for (int e : ret) {
            System.out.print(e + " ");
        }
        System.out.println();
        for (int e : arr2) {
            System.out.print(e + " ");
        }

    }
    public static void main1(String[] args) {
        char[] charr = {'c', 'a'};

        int[] arr;
        // arr = {1,2,3};    分开的话不可省略 new int[]
        arr = new int[]{1,2,3};

        for (int i = 0; i < charr.length; ++i) {
            System.out.println(charr[i]);
        }
        for (int i = 0; i < arr.length; ++i) {
            System.out.println(arr[i]);
        }
    }
}
